<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="mytags" uri="/WEB-INF/mytags.tld" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.STYLE1 {font-size: 12px}
.STYLE3 {font-size: 12px; font-weight: bold; }
.STYLE4 {
	color: #03515d;
	font-size: 12px;
}

.tdclass{
	height: 20;
	background-color: #FFFFFF;
}
-->
</style>
<script type="text/javascript" src="<%=path %>/common/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/common/mark-ui.js"></script>
<script type="text/javascript" src="<%=path %>/common/selectTree.js"></script>
<script type="text/javascript" src="<%=path %>/common/formValidator/formValidator-4.1.1.js" charset="UTF-8"></script>
<script type="text/javascript" src="<%=path %>/common/formValidator/formValidatorRegex.js" charset="UTF-8"></script>
<script type="text/javascript">
	if('${saveFlag}'!=''){
	if('${saveFlag}'=='1'){
		alert('保存成功！');
		parent.refesh();
	}else{
		alert('保存失败，数据重复！');
	}
	}
	function reback(){
		closeWin();
	}
</script>
<script type="text/javascript">

	jQuery(document).ready(function(){
	
		jQuery.formValidator.initConfig({formID:"form1",theme:'ArrowSolidBox',mode:'AutoTip',onError:function(msg){alert(msg)},inIframe:true});
		jQuery("#areaName").formValidator({onShow:"请输入区域名称",onFocus:"请输入区域名称",onCorrect:"区域名称正确"}).inputValidator({min:1,onErrorMin:"区域名称不能为空",onErrorMax:"区域名称不能>50",max:50});
		//jQuery("#areaCode").formValidator({onShow:"请输入区域代码",onFocus:"请输入区域代码",onCorrect:"区域代码正确"}).inputValidator({min:1,onErrorMin:"区域代码不能为空",onErrorMax:"区域代码不能>50",max:50});
		
	});
	function selRoad(id,name){
	var url="<%=path %>/pages/admin/parkarea/dmb_tree.jsp";
		selectTree(url,id,name);
		
	}
	function selCheck(obj){
			jQuery("input[name='ids']").each(function(){
	  			$(this).attr("checked",obj.checked);
	  		});
	}
</script>


<script type="text/javascript">
		function getChecks(id){
			var str ="";
			str+="<div align=\"center\" class=\"STYLE1\">";
			str += "<input type=\"checkbox\" name=\"ids\" value=\"checkbox\" />"; 
			str +="</div>";
			return str;
		}
		function getArea(id){
		
			var str ="";
			str+="<div align=\"center\" class=\"STYLE1\">";
			str += "<input name='dmbList["+id+"].nid' id='nid" + id + "' type='hidden' />"; 
			str += "<input name='dmbList["+id+"].road' id='road" + id + "' type='text' maxlength='100' "; 
			str+=" onclick=\"selRoad('nid"+id+"','road"+id+"')\"";
			str+="/>";
			str +="</div>";
			return str;
		}
		function getRoadType(id){
			var str ="";
			str+="<div align=\"center\" class=\"STYLE1\">";
			str ="<select name='dmbList["+id+"].type' id='type" + id + "' >";
			str = str +"<option  value='1'>进口</option>";
			str = str +"<option  value='1'>出口</option>";
			str = str + "</select>";
			str +="</div>";
			return str;
		}
	
		function getButton(id){
			var str ="<img src='${pageContext.request.contextPath }/images/delete.gif' border='0' />";
			return str;
		}
		
		function findObj(theObj, theDoc) {
		var p, i, foundObj;
		if (!theDoc) {
			theDoc = document;
		}
		if ((p = theObj.indexOf("?")) > 0 && parent.frames.length) {
			theDoc = parent.frames[theObj.substring(p + 1)].document;
			theObj = theObj.substring(0, p);
		}
		if (!(foundObj = theDoc[theObj]) && theDoc.all) {
			foundObj = theDoc.all[theObj];
		}
		for (i = 0; !foundObj && i < theDoc.forms.length; i++) {
			foundObj = theDoc.forms[i][theObj];
		}
		for (i = 0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) {
			foundObj = findObj(theObj, theDoc.layers[i].document);
		}
		if (!foundObj && document.getElementById) {
			foundObj = document.getElementById(theObj);
		}
		return foundObj;
	}
		function AddSignRow(tableId) {
		var txtTRLastIndex = findObj("txtTRLastIndex", document);
		var rowID = parseInt(txtTRLastIndex.value);
		var signFrame = findObj(tableId, document);
		
		var newTR = signFrame.insertRow(signFrame.rows.length);
		newTR.id = "SignItem" + rowID;
	 	newTR.className = "listdetail";
	 	
	 	var td1 = newTR.insertCell(0);
		td1.className = "tdclass";
		td1.style.textAlign ="center";
		td1.innerHTML = getChecks(rowID,newTR.id);
		
		var td2 = newTR.insertCell(1);
		td2.className = "tdclass";
		td2.style.textAlign ="center";
		td2.innerHTML = "<div align=\"center\" class=\"STYLE1\">"+(rowID).toString()+"</div>";
		
		var td3 = newTR.insertCell(2);
		td3.className = "tdclass";
		td3.style.textAlign ="center";
		td3.innerHTML = getArea(rowID);
	 
		var td4 = newTR.insertCell(3);
		td4.className = "tdclass";
		td4.style.textAlign ="center";
		td4.innerHTML = getRoadType(rowID);
		
		var td5 = newTR.insertCell(4);
		td5.className = "tdclass";
		td5.style.textAlign ="center";
		td5.innerHTML = "<div align=\"center\" class=\"STYLE1\" style=\"cursor: hand;\" onclick=\"DeleteSignRow('SignItem"+rowID+"','"+tableId+"')\"> &nbsp;<img src=\"<%=path %>/parkdemo/images/del.gif\" width=\"16\" height=\"16\" />删除</div>";
		
		txtTRLastIndex.value = (rowID + 1).toString();
	}
	
	function DeleteSignRow(rowid,tableId) {
		var signFrame = findObj(tableId, document);
		var signItem = findObj(rowid, document);
	
		var rowIndex = signItem.rowIndex;
		signFrame.deleteRow(rowIndex);
	 
		for (i = rowIndex; i < signFrame.rows.length; i++) {
			signFrame.rows[i].cells[1].innerHTML = "<div align=\"center\" class=\"STYLE1\">"+(i-1).toString()+"</div>";
		}
	}
	
	function deleteMutilRow(){
		jQuery("input[name='ids'][checked]").each(function(){
			
		});
	}

</script>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="30" background="<%=path %>/images/tab_05.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="30"><img src="<%=path %>/images/tab_03.gif" width="12" height="30" /></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="46%" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="5%"><div align="center"><img src="<%=path %>/images/tb.gif" width="16" height="16" /></div></td>
                <td width="95%" class="STYLE1"><span class="STYLE3">你当前的位置</span>：[系统管理]-[景区区域信息编辑]</td>
              </tr>
            </table></td>
            <td width="54%"><table border="0" align="right" cellpadding="0" cellspacing="0">
              <tr>
                
                <td width="82"><table width="88%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td class="STYLE1"><div align="center"><img src="<%=path %>/images/tb.gif" width="14" height="14" /></div></td>
                    <td class="STYLE1"><div align="center" style="cursor: hand;" onclick="reback();">返回列表</div></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
          
        </table></td>
        <td width="16"><img src="<%=path %>/images/tab_07.gif" width="16" height="30" /></td>
      </tr>
      
    </table></td>
  </tr>
  

  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
    
      <tr>
        <td width="8" background="<%=path %>/images/tab_12.gif">&nbsp;</td>
        <td><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6" >
            <s:form action="/admin/Parkarea_save.action" method="post" name="form1" id="form1">
            <input type="hidden" name="vo.id" value="${vo.id }" />
             <input type="hidden" name="vo.pid" value="${vo.pid }" />
            <tr>
            <td colspan="2" width="20%" height="52" bgcolor="#FFFFFF"><div align="center">
              【景区区域信息编辑】
            </div></td>
          </tr>
          <tr>
            <td colspan="1" width="20%" height="22" bgcolor="#FFFFFF"><div align="right">
              区域名称：
            </div></td>
            <td colspan="1" height="32" bgcolor="#FFFFFF"><div align="left">
              &nbsp;<input id="areaName" type="text" name="vo.areaName" value="${vo.areaName }" />
            </div></td>
            
          </tr> 
          <tr>
            <td colspan="2" width="100%" height="22" bgcolor="#FFFFFF"><div align="center">
              <table width="100%" id="dmbTable">
              
              <tr>
            <td colspan="7" width="3%" height="22" background="<%=path %>/parkdemo/images/bg.gif" bgcolor="#FFFFFF"><div align="right">
              <table border="0" align="right" cellpadding="0" cellspacing="0">
              <tr>
               
                <td width="60"><table width="90%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td class="STYLE1"><div align="center"><img src="<%=path %>/parkdemo/images/22.gif" width="14" height="14" /></div></td>
                    <td class="STYLE1"><div align="center">
                    <input type="hidden" value="<s:property value="dmbList.size()+1" />" name=txtTRLastIndex id="txtTRLastIndex">
                    <a href="javascript:void(0)" onclick="setTimeout(function(){AddSignRow('dmbTable');},50);">新增</a>
                    </div></td>
                  </tr>
                </table></td>
                
                <td width="52"><table width="88%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td class="STYLE1"><div align="center"><img src="<%=path %>/parkdemo/images/11.gif" width="14" height="14" /></div></td>
                    <td class="STYLE1"><div align="center">删除</div></td>
                  </tr>
                </table></td>
              </tr>
            </table>
            </div></td>
            
          </tr>
             <tr>
            <td width="3%" height="22" background="<%=path %>/parkdemo/images/bg.gif" bgcolor="#FFFFFF"><div align="center">
              <input type="checkbox" name="checkbox" value="checkbox" onclick="selCheck(this);" />
            </div></td>
            <td width="3%" height="22" background="<%=path %>/parkdemo/images/bg.gif" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1">序号</span></div></td>
            <td width="12%" height="22" background="<%=path %>/parkdemo/images/bg.gif" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1">车道名称</span></div></td>
            <td width="14%" height="22" background="<%=path %>/parkdemo/images/bg.gif" bgcolor="#FFFFFF"><div align="center"><span class="STYLE1">进出口类型</span></div></td>
            <td width="15%" height="22" background="<%=path %>/parkdemo/images/bg.gif" bgcolor="#FFFFFF" class="STYLE1"><div align="center">基本操作</div></td>
          </tr>
          
			<s:iterator value="dmbList" var="entity" status="v">
				<tr id="tr${v.index}">
		            <td class="tdclass"><div align="center" class="STYLE1">
		              <input type="checkbox" name="ids" value="checkbox" />
		            </div></td>
		            <td class="tdclass"><div align="center" class="STYLE1">
		              ${v.index+1}
		            </div></td>
		            <td class="tdclass"><div align="center" class="STYLE1">
			            <s:hidden id="nid%{#v.index}" name="%{'dmbList['+#v.index+'].nid'}"></s:hidden>
			            <s:textfield id="road%{#v.index}" name="%{'dmbList['+#v.index+'].road'}" onclick="selRoad('nid%{#v.index}','road%{#v.index}');"></s:textfield>
		            </div></td>
		            <td class="tdclass"><div align="center" class="STYLE1">
		            	<s:select name="%{'dmbList['+#v.index+'].type'}" list="#{'1':'进口','2':'出口'}"></s:select>
		            </div></td>
		            <td class="tdclass"><div align="center" class="STYLE1" style="cursor:hand;" onclick="DeleteSignRow('tr${v.index}','dmbTable')"> &nbsp;<img src="<%=path %>/parkdemo/images/del.gif" width="16" height="16" />删除</div></td>
	          	</tr>
			</s:iterator>
              
              </table>

            </div></td>
            
            
          </tr> 
           <tr>
            <td colspan="2" width="20%" height="52" bgcolor="#FFFFFF"><div align="center">
              &nbsp;<input id="subId" type="submit" value="提交">&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" onclick="reback();" value="返回">
            </div></td>
           
            
          </tr>
          </s:form>
        </table></td>
        <td width="8" background="<%=path %>/images/tab_15.gif">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="35" background="<%=path %>/images/tab_19.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="12" height="35"><img src="<%=path %>/images/tab_18.gif" width="12" height="35" /></td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td class="STYLE4">&nbsp;&nbsp;</td>
            <td></td>
          </tr>
        </table></td>
        <td width="16"><img src="<%=path %>/images/tab_20.gif" width="16" height="35" /></td>
      </tr>
    </table></td>
  </tr>
</table>
<div id="output"></div>
</body>
</html>
